<template>
    <div class="page-container">
        <h1 class="page-title">心理健康测评</h1>
        <div class="content-wrapper">
            <el-card class="intro-card" shadow="hover">
                <template #header>
                    <div class="card-header">
                        <h2>心理健康测评简介</h2>
                    </div>
                </template>
                <div class="card-content">
                    <p>
                        通过心理健康测评，您可以了解自己的心理状态，发现潜在的心理问题，并获取专业的建议。
                    </p>
                    <p>
                        我们提供多种专业的心理测评量表，包括抑郁量表、焦虑量表、压力量表等，帮助您全面了解自己的心理健康状况。
                    </p>
                </div>
            </el-card>

            <div class="assessment-list">
                <el-card
                    v-for="(item, index) in assessmentList"
                    :key="index"
                    class="assessment-card"
                    shadow="hover"
                >
                    <div class="assessment-icon">
                        <el-icon :size="40" :color="'#4086f4'">
                            <component :is="getIconComponent(item.icon)" />
                        </el-icon>
                    </div>
                    <h3>{{ item.title }}</h3>
                    <p>{{ item.description }}</p>
                    <div class="card-footer">
                        <span class="time-info"
                            >预计用时: {{ item.estimatedTime }}分钟</span
                        >
                        <el-button
                            type="primary"
                            size="small"
                            @click="startAssessment(item)"
                            >开始测评</el-button
                        >
                    </div>
                </el-card>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import {
    Aim,
    Lightning,
    WindPower,
    MoonNight,
    Sunrise
} from '@element-plus/icons-vue'

// 获取图标组件
const getIconComponent = (iconName) => {
    const iconMap = {
        Lightning: Lightning,
        MoonNight: MoonNight,
        WindPower: WindPower,
        Sunrise: Sunrise,
        Aim: Aim
    }
    return iconMap[iconName] || Aim
}

// 测评列表
const assessmentList = ref([
    {
        id: 1,
        title: '焦虑自评量表(SAS)',
        description: '用于评估个体主观体验到的焦虑程度和症状',
        icon: 'Lightning',
        estimatedTime: 10
    },
    {
        id: 2,
        title: '抑郁自评量表(SDS)',
        description: '用于评估个体主观体验到的抑郁程度和症状',
        icon: 'MoonNight',
        estimatedTime: 10
    },
    {
        id: 3,
        title: '心理压力自评量表(PSS)',
        description: '测量您在过去一个月中感知到的压力水平',
        icon: 'WindPower',
        estimatedTime: 8
    },
    {
        id: 4,
        title: '心理健康综合测评',
        description: '全面评估您的心理健康状况，包括情绪、压力和人际关系等方面',
        icon: 'Sunrise',
        estimatedTime: 20
    }
])

// 开始测评
const startAssessment = (item) => {
    console.log('开始测评', item)
    // 这里可以跳转到具体的测评页面
}
</script>

<style scoped>
.page-container {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.page-title {
    font-size: 24px;
    color: #333;
    margin-bottom: 20px;
    font-weight: normal;
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.intro-card {
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 18px;
    color: #333;
    margin: 0;
    font-weight: normal;
}

.card-content p {
    margin-bottom: 10px;
    line-height: 1.6;
    color: #666;
}

.assessment-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.assessment-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.3s;
}

.assessment-card:hover {
    transform: translateY(-5px);
}

.assessment-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.assessment-card h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 10px;
    font-weight: normal;
    text-align: center;
}

.assessment-card p {
    color: #666;
    line-height: 1.6;
    flex-grow: 1;
    margin-bottom: 15px;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.time-info {
    color: #999;
    font-size: 12px;
}

@media (max-width: 768px) {
    .assessment-list {
        grid-template-columns: 1fr;
    }
}
</style>
